Map Data to Controls
Once you have added and configured a Data Source, you can link its data items to Controls on your forms in order for the values within the data items to be displayed, input and/or edited. You can map a Control directly to a Data Source data item or you can use Custom Views to filter records and combine data from multiple tables.
Controls can have input and output mappings. An input mapping will enter a value into the Control from the mapped data item. An output mapping will take the value in the Control and enter it into a data record. The Scripting facility allows you to control when data is transferred between a data record and a Control.
Most Controls allow both input and output mappings but some, such as the ListView Control, only allow input mappings.
Custom View data items can be mapped to Controls in the same way as Data Source data items but they can only be used to input a value to a Control. Changes to the Control's value made by a user cannot be updated via a Custom View but must use the Data Source directly.
- The ListView Control is different to other Controls in that it allows you to display multiple columns of data in a single Control – for information about configuring the Control see The ListView Control.
There are a number of ways to map data items to a Control:
-
Drag the data item from the Data Sources tree onto the Control. The Add Data Mapping dialog box will be displayed showing the full name of the data item, the name of the Control and a combo-box to select the direction in which data can move in relation to the Control. Select Input if the value of the Control is to be taken from the data value, Output if the value of the Control is used to set the value of the data item and Input/Output if you want the starting value of the Control to be taken from the data value and the data value to be updated if the Control value changes.
When you have finished, choose the OK button to accept your choices or Cancel to abandon adding this item.
If you choose OK, the Control Data Mapping dialog box will appear. This displays the new state of the mappings for the Control. Choose the OK button to close the dialog box and continue with your Project.
-
Select the Control. The Control's Properties will be displayed in the Properties Pane. Under the Mapped Data Property category, you will find the Input and Output Properties.
Click on the value of one of these Properties and then on the arrow at the right-hand side to drop down a list of all the data items currently defined, from which you can select the one to map to this Control. If the Property is set to (none), no data item is mapped for that data direction. You can set a mapping for just one of the two Properties or for both. If you are setting a value for both, you can set them to the same data item or to different items, if you want the original value displayed by the Control to come from one source and any change to update a second one.
-
Right-click on a Control and choose Data Mapping Properties from the menu. This will display the Control Data Mapping dialog box, showing the current mappings for the Control. If no data items have been mapped to this Control, you can set a mapping by clicking on the value field of the Input or Output option and selecting the required data item from the drop-down list. As with the other methods above, you can map an item for Input only, Output only or for both.
-
When mapping data to/from a Soap Web Service, you may find that the Input/Output Properties' drop-down lists include pairs of similar items in the following formats:
<servicename>.<functionname>.<parametername>
<servicename>.<functionname>.<parametername>.<parametername>
The first item, <servicename>.<functionname>.<parametername>, refers to the column in the database table, the value of which will be the contents of the database field. In the second item, <servicename>.<functionname>.<parametername>.<parametername>, the final <parametername> refers explicitly to the XML within the database field, somewhat confusingly having the same name as the database column. When mapping an Input or Output, you should use the first item which refers to the data column rather than the second referring to the XML contained within the column.